package com.zzyl.sex.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.sex.domain.SexService;
import com.zzyl.sex.service.ISexServiceService;
import com.zzyl.common.utils.poi.ExcelUtil;
import com.zzyl.common.core.page.TableDataInfo;

/**
 * 性服务Controller
 * 
 * @author 张亮
 * @date 2025-09-14
 */
@RestController
@RequestMapping("/sex/service123")
@Api(tags = "性服务的接口")
public class SexServiceController extends BaseController
{
    @Autowired
    private ISexServiceService sexServiceService;

    /**
     * 查询性服务列表
     */
//    @PreAuthorize("@ss.hasPermi('sex:service123:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询性服务列表")
    public TableDataInfo list(SexService sexService)
    {
        System.out.println("123");
        startPage();
        List<SexService> list = sexServiceService.selectSexServiceList(sexService);
        return getDataTable(list);
    }

    /**
     * 导出性服务列表
     */
    @PreAuthorize("@ss.hasPermi('sex:service123:export')")
    @Log(title = "性服务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出性服务列表")
    public void export(HttpServletResponse response, SexService sexService)
    {
        List<SexService> list = sexServiceService.selectSexServiceList(sexService);
        ExcelUtil<SexService> util = new ExcelUtil<SexService>(SexService.class);
        util.exportExcel(response, list, "性服务数据");
    }

    /**
     * 获取性服务详细信息
     */
    @PreAuthorize("@ss.hasPermi('sex:service123:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取性服务详细信息")
    public AjaxResult getInfo(@ApiParam(value = "性服务ID",required = true) @PathVariable("id") String id)
    {
        return success(sexServiceService.selectSexServiceById(id));
    }

    /**
     * 新增性服务
     */
    @PreAuthorize("@ss.hasPermi('sex:service123:add')")
    @Log(title = "性服务", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增性服务")
    public AjaxResult add(@ApiParam(value = "新增性服务实体") @RequestBody SexService sexService)
    {
        return toAjax(sexServiceService.insertSexService(sexService));
    }

    /**
     * 修改性服务
     */
    @PreAuthorize("@ss.hasPermi('sex:service123:edit')")
    @Log(title = "性服务", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改性服务")
    public AjaxResult edit(@RequestBody SexService sexService)
    {
        return toAjax(sexServiceService.updateSexService(sexService));
    }

    /**
     * 删除性服务
     */
    @PreAuthorize("@ss.hasPermi('sex:service123:remove')")
    @Log(title = "性服务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value = "删除性服务")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sexServiceService.deleteSexServiceByIds(ids));
    }
}
